<template>
    <div>
        <a-tabs v-model="tab">
            <a-tab-pane key="/followList" tab="关注">
                <a-list>
                    <a-list-item v-for="i in list.follow" :key="i.id">
                        <a-list-item-meta>
                            <a slot="title" target="_blank" style="font-weight: bold" :href="'https://jxjlife.cn/user/'+i.id">{{i.name}}</a>
                        </a-list-item-meta>
                        <a-button size="small" @click="unfollow(i.id)">取消关注</a-button>
                    </a-list-item>
                </a-list>
            </a-tab-pane>
            <a-tab-pane key="/fansList" tab="粉丝">
                <a-list>
                    <a-list-item v-for="i in list.fans" :key="i.id">
                        <a-list-item-meta>
                            <a slot="title" target="_blank" style="font-weight: bold" :href="'https://jxjlife.cn/user/'+i.id">{{i.name}}</a>
                        </a-list-item-meta>
<!--                        <a-button size="small" @click="unfollow(i.id)">取消关注</a-button>-->
                    </a-list-item>
                </a-list>
            </a-tab-pane>
        </a-tabs>
    </div>
</template>

<script>
    export default {
        name: "Follow",
        data(){
            return{
                list: [],
                tab: this.$route.path,
            }
        },
        watch:{
            tab(){
                this.$router.push(this.tab);
            }
        },
        created() {
            this.getData();
        },
        methods:{
            getData(){
                const t = this;
                axios.get('/user/followList').then(function (resp) {
                    t.list = resp.data;
                })
            },
            unfollow(id){
                const t = this;
                axios.get('/user/unfollow/'+id).then(function (resp) {
                    t.getData();
                    t.$message.success('已取消');
                })
            }
        }
    }
</script>

<style scoped>

</style>